#include <stdio.h>
#include "stdlib.h"
//typedef int ElementType;
typedef char ElementType;
typedef struct LNode *List;
struct LNode{
    ElementType data;
    List next;
    List prev;
};
List listInit() {
    List s ;
    s = (List) malloc(sizeof (struct LNode));
    if(s == NULL) {
        printf("申请节点失败!");
    }
    s->next = NULL;
    s->prev = NULL;
    return s;
}
void addLast(List Ptr, ElementType x) {
    List cur,s;
    s = Ptr;
    cur = (List) malloc(sizeof (struct LNode));
    while(s->next != NULL){
        s = s->next;
    }
    cur->data = x;
    cur->next = NULL;
    cur->prev = s;
    s->next = cur;
    return;

}
void addFirst(List Ptr,ElementType x) {
    List cur,s;
    cur = Ptr;
    s = (List) malloc(sizeof (struct LNode));
    s->data = x;
    s->next = cur->next;
    cur->next = s;
    s->prev = cur;
    return;
}


int main() {
    List L1;
    L1 = listInit();
    List cur1 = L1;
    addLast(L1,'1');
    addFirst(L1,'3');
    printf("%c ",L1->next->next->data);
//    while(cur1) {
//        printf("%d ",cur1->data);
//        cur1 = cur1->next;
//    }
    return 0;
}
